package com.koron.car.web.maintain.bean.vo;

import com.koron.car.config.Constants;
import com.koron.car.web.maintain.bean.entity.AcceptRecord;
import com.koron.car.web.maintain.bean.entity.CarMaintain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @author twcao
 * @title: CarMaintainVO
 * @projectName GDH_EAM_V2
 * @description: 维修申请详情
 * @date 2022/3/1315:06
 */
@Data
@ApiModel("维修申请详情")
public class CarMaintainVO extends CarMaintain {

    @ApiModelProperty(value = "当前节点名称")
    private String currNodeName;

    @ApiModelProperty(value = "当前节点处理人")
    private String currNodeUser;

    @ApiModelProperty("累计行驶距离，结束用车后更新，单位：公里")
    private Double totalDistance;

    @ApiModelProperty("使用年限")
    private Double usingYear;

    @ApiModelProperty("车辆验收记录列表（用于回显）")
    private List<AcceptRecord> accepts;

    @ApiModelProperty("车辆验收记录")
    private AcceptRecord accept;

    @ApiModelProperty("车架号")
    private String frame;

    @ApiModelProperty("车队id")
    private String motorcade;

    @ApiModelProperty("车队名称")
    private String motorcadeName;

    @ApiModelProperty("车辆单位名称")
    private String ownerOrgName;

    @ApiModelProperty("用于工作流条件判断：${(appointPlace=='1' && appraise < 3000) ||  (appointPlace=='0' && appraise < 1500)}")
    private String appoint;

    @ApiModelProperty("是否为巨额维修/保养，用于工作流条件判断: appraise >= 15000")
    private String hugeSum;

    @ApiModelProperty("是否为基层用车，保存后由后端判断设值")
    private String primary;

    public String getAppoint() {
        if((this.getAppointPlace() == Constants.YesOrNo.YES && this.getAppraise() < 3000)
        || (this.getAppointPlace() == Constants.YesOrNo.NO && this.getAppraise() < 1500)) {
            return String.valueOf(Constants.YesOrNo.YES);
        } else {
            return String.valueOf(Constants.YesOrNo.NO);
        }
    }

    public String getHugeSum() {
        return this.getAppraise() < 15000 ? String.valueOf(Constants.YesOrNo.NO) : String.valueOf(Constants.YesOrNo.YES);
    }

}
